//
//  VipAddrSearchResultController.m
//  CenturyCity
//
//  Created by nsm on 2019/6/13.
//  Copyright © 2019 beisheng. All rights reserved.
//

#import "VipAddrSearchResultController.h"

@implementation VipAddrSearchResultController
@synthesize didSelectResultItem = _didSelectResultItem;

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableHeaderView = UIView.new;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    id item = tableView.sourceManager.dataArray[indexPath.row];
    !self.didSelectSearchResult?:self.didSelectSearchResult(item);
}

- (void)searchWithObject:(id)obj {
    NSString *text = @"";
    if ([obj isKindOfClass:NSString.class])
        text = SafeString(obj);
    else if ([obj isKindOfClass:NSDictionary.class])
        text = SafeString(obj[@"title"]);
    
    self.tableView.parameters = @{@"keyword": text};
    [self.tableView beginRefreshing:RefreshHudDefault];
}

@end
